package com.cc.study.auto;

import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class TestAutowire {
    @Test
    public void demo01(){
        String xmlPath = "auto.xml";
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext(xmlPath);
        User user = (User) applicationContext.getBean("userId");
        System.out.println(user.getUname());
        System.out.println(user.getAddress().getAddr());
        System.out.println(user.getAddress().getTel());
    }
    @Test
    public void demo02(){
        String xmlPath = "auto.xml";
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext(xmlPath);
        User user = (User) applicationContext.getBean("userId2");
        System.out.println(user.getUname());
        System.out.println(user.getAddress().getAddr());
        System.out.println(user.getAddress().getTel());
    }
    @Test
    public void demo03(){
        String xmlPath = "auto.xml";
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext(xmlPath);
        User user = (User) applicationContext.getBean("userId3");
        System.out.println(user.getUname());
        System.out.println(user.getAddress().getAddr());
        System.out.println(user.getAddress().getTel());
    }
}
